package com.myzf.ncov.get;

import com.myzf.ncov.entity.PneumoniaProperties;
import com.myzf.ncov.service.DataHandleService;
import com.myzf.ncov.utils.GetDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * 获取数据
 *
 * @author limuyi
 * @version V1.0
 * Created by limuyi on 2020-02-01 14:28
 */
@Component
public class GetData {

    @Autowired
    private PneumoniaProperties pneumoniaProperties;

    @Autowired
    @Qualifier("situationDataHandleServiceImpl")
    private DataHandleService situationDataHandleService;

    @Autowired
    @Qualifier("realTimeReportDataHandleServiceImpl")
    private DataHandleService realTimeReportDataHandleService;

    /**
     * 获取数据肺炎疫情数据
     */
    public void getPneumoniaEpidemicSituationData() {
        // 1.获取数据
        String result = GetDataUtil.request(pneumoniaProperties.getUrl(),
                String.format("version=%s&appid=%s&appsecret=%s",
                        "epidemic", pneumoniaProperties.getAppId(),
                        pneumoniaProperties.getAppSecret()));
        // 2.给相应的类进行处理
        situationDataHandleService.deal("situation-data", result);
    }

    /**
     * 获取疫情实时报告的数据
     */
    public void getSituationRealTimeReportData() {
        /*// 1.获取数据
        String result = GetDataUtil.request(String.format("%s%s", URL, "/ncov/index"),
                String.format("%s%s", "key=", pneumoniaProperties.getKey()));
        // 2.给相应的类进行处理
        realTimeReportDataDealServiceI.deal("real-time-report-data", result);*/
    }
}
